<div id="breadcrumb">
<a href="/anchor" class="go-to-home tip-bottom font font18" data-original-title="Go to Home">
<i class="icon-arrow-left"></i> 返回 &nbsp;
</a> 
<a href="#" class="font font18"> &nbsp;&nbsp;<span>主播 &gt</span></a>
<a href="#" class="font font18"> <span>{{anchorInfo['status']}}&gt</span></a>
<a href="#" class="current font font18"> <span>主播详情</span></a>
</div>

<!--sidebar-menu-->
<div id="sidebar" class="clearfix">
    <div class="user-info">
        <img alt="" src="{{anchorInfo['avatar']}}">

        <p>
            <span class="font font20 cr-dpe">{{anchorInfo['nickName']}}</span>
        </p>
        <p>
            <span class="font font20 cr-dpe" id="_uid">{{anchorInfo['uid']}}</span>
            <input id="in_uid" type="hidden" value="{{anchorInfo['uid']}}">
        </p>
        <p>
            <span class="i-actor sprite-zb_level zb{{anchorInfo['level2']}}"></span><span class="font font20 cr-dpe">{{anchorInfo['name']}}</span>
        </p>
        <p>
            <!-- <span class="font font20 cr-dpe">{{anchorInfo['status']}}</span> -->
            <span class="font font20 cr-dpe">
                {{anchorInfo['status']}}
                {% if anchorInfo['status']=='已签约' and !familyId %}<!--  -->
                <button class="btn" onclick="unbind({{anchorInfo['uid']}})">解约</button>
                {% endif %}
            </span>
        </p>
    </div>
  <div class="progtrckr-box" style="top:260px;">
    <div class="progtrckrline" ></div>
    <ul class="progtrckr" style="width: 212px;">
        <li ><i class="custom-icon custom-icon-point"></i><a href="/anchor/anchorinfo?uid={{anchorInfo['uid']}}">个人资料</a></li>
        <li><i class="custom-icon custom-icon-point"></i><a href="/anchor/income?uid={{anchorInfo['uid']}}">收益</a></li>
        <li><i class="custom-icon custom-icon-point"></i><a href="/anchor/fans?uid={{anchorInfo['uid']}}">粉丝</a></li>
        <li><i class="custom-icon custom-icon-point"></i><a href="/anchor/contribute?uid={{anchorInfo['uid']}}">贡献</a></li>
        <li><i class="custom-icon custom-icon-point"></i><a href="/anchor/trend?uid={{anchorInfo['uid']}}">趋势分析</a></li>
        <li class="active"><i class="custom-icon custom-icon-point"></i><a href="/anchor/worktable?uid={{anchorInfo['uid']}}">导出工作情况表</a></li>
    </ul>
  </div>
</div>
<!--end sidebar-menu-->

<div id="applyinfo_content" style="  margin-left: 230px;">
    <div class="container-fluid" style="padding: 0;">
        <div class="widget-box tab-tabs" >
            <div class="widget-title">

            </div>
            <div class="widget-content tab-content">
                <div id="tab1" class="tab-pane active">
                    <div class="container-fluid">
                        <div class="row-fluid" style="margin: 20px 0;overflow: hidden;">

                        </div>
                        <div class="row-fluid" style="border: 1px solid #ddd;font-size: 16px;margin-bottom: 20px;">
                            <div style="height: 50px;color: #817CCE;line-height: 50px;border-bottom: 2px solid #ddd;margin: 0 20px;">导出旗下所有主播在一段时间内的工作情况，导出excel</div>
                            <div style="height:50px;margin: 10px 20px 0;">
                                <span>请选择起止日期</span>
                                <a class="date-calendar " style="margin-left: 8px;"><i class=" icon-calendar"></i> <input id="mydate"  placeholder="请输入日期"  value="" style="height: 34px;"></a>
                                <button  class="btn btn-purple" onclick="getDataList()">查询</button>
                                <form action="/ajax/protoDataExcel" method="post" style="margin: -36px 0 0 410px;" onsubmit="return exceldataSubmit()">
                                    <input type="hidden" value="{{anchorInfo['uid']}}" name="uid">
                                    <input type="hidden" value="" name="startTime" id="_startTime">
                                    <input type="hidden" value="" name="endTime" id="_stopTime">
                                    <button  type="submit" class="btn btn-purple">导出表格</button>
                                </form>
                            </div>
                        </div>
                        <div class="row-fluid">
                            <table id="tableList" class="table with-check table-purple">
                                <thead>
                                <tr>
                                    <th>日期</th>
                                    <th>播出起止时间</th>
                                    <th>播出时长</th>
                                    <th>收益（聊币）</th>
                                </tr>
                                </thead>
                                <tbody>

                                </tbody>
                            </table>
                        </div>

                        {% include "common/pagination.html" %}
                    </div>
                </div>


            </div>
        </div>

    </div>
</div>

<script src="{{static_url('web/js/daterangepicker.jQuery.js')}}"></script>
<link rel="stylesheet" href="{{static_url('web/css/ui.daterangepicker.css')}}">
<script type="text/javascript" src="{{static_url('web/js/91ns.anchor1.js')}}"></script>
<script type="text/javascript">

    $(function(){
        $('body').addClass('anchorinfo');

        getDataList();

        $('#mydate').daterangepicker({
                    presetRanges:[
                        //{text:'最近一周', dateStart:'yesterday-7days', dateEnd:'yesterday' },
                        //{text:'最近一月', dateStart:'yesterday-1month', dateEnd:'yesterday' },
                        //{text:'最近一年', dateStart:'yesterday-1year', dateEnd:'yesterday' }
                    ],
                    presets:{
                        dateRange:'自定义时间'
                    },
                    rangeStartTitle:'起始日期',
                    rangeEndTitle:'结束日期',
                    nextLinkText:'下月',
                    prevLinkText:'上月',
                    doneButtonText:'确定',
                    cancelButtonText:'取消',
                    earliestDate:'',
                    latestDate:Date.parse('today'),
                    constrainDates:true,
                    rangeSplitter:'-',
                    dateFormat:'yy-mm-dd',
                    closeOnSelect:false,
                    onOpen:function(){
                        $('.ui-daterangepicker-dateRange').click().parent().hide();
                        $('.ui-daterangepickercontain').css({left:($('#mydate').offset().left-120)+'px'});
                    },
                    onClose:function(){
//                        var typer=$('#mydate').attr('data');
                        var b=$('#mydate').val();
                        var timeBegin= b.substring(0,10);
                        var timeEnd= b.substring(12,23);
                        $('#_startTime').val(timeBegin);
                        $('#_stopTime').val(timeEnd);

                    }
                }
        );
    });
    function exceldataSubmit(){
        var start=$('#_startTime').val();
        var end=$('#_stopTime').val();
        if(start==''&& end=='')
        {
            alert('请选择时间');
            return false;
        }
        else if(start==''){
            alert('请选择时间');
            return false;
        }
        else{
            return true;
        }
    }

    function getDataList(index){

        var b=$('#mydate').val();
        var timeBegin= b.substring(0,10);
        var timeEnd= b.substring(12,23);

        var data={};
        data.page=index||1;
        data.pageSize=global.pageSize;
        data.uid=$('#in_uid').val();
        data.startTime=timeBegin;
        data.endTime=timeEnd;

        $.ajax({
            type:"POST",
            data:data,
            url:'/ajax/anchorWorkingData',
            dataType:'json',
            success:function(res){
                var data=res.data;
                var tableList=document.getElementById("tableList");
                var tbody= tableList.getElementsByTagName('tbody')[0];
                dataTable.clearData(tbody);

                var count=document.getElementById('count');
                count.innerHTML=data.count;

                for(var i=0;i<data.list.length;i++){
                    addRow(tbody,data.list[i]);
                }
                if(!index||index==0){
                    utilsPagination("#pagination",data.count,global.pageSize,function(page_index,jq){
                        page_index+=1;
                        getDataList(page_index);
                    });
                }
            }
        });
    }

    function addRow(table,data){
        var row=table.insertRow();
        var cell=row.insertCell(0);
        var cell1=row.insertCell(1);
        var cell2=row.insertCell(2);
        var cell3=row.insertCell(3);

        cell.innerHTML=data.dayTime;

        var div=document.createElement("div"),
                span1=document.createElement("span"),
                span2=document.createElement("span");

        div.className="anchor-info";
        span1.innerHTML=data.publicTime+'&nbsp;&nbsp;至&nbsp;&nbsp;';
        span2.innerHTML=data.endTime;


        div.appendChild(span1);
        div.appendChild(span2);

        cell1.appendChild(div);

        if(data.length>=60){
            var hourL=(Math.floor(data.length/3600)+"小时"+Math.floor((data.length%3600)/60)+"分钟");
        }
        else{
            var hourL='0小时0分'+data.length+'秒';
        }
        cell2.innerHTML=hourL;
        cell3.innerHTML=data.income;
        return row;
    }
</script>